﻿using AirlineBookingSystem.Flight.Application.Queries;
using AirlineBookingSystem.Flight.Core.Entities;
using AirlineBookingSystem.Flight.Core.Repositories;
using MediatR;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AirlineBookingSystem.Flight.Application.Handlers
{
    public class GetAllFlightsHandler : IRequestHandler<GetAllFlightsQuery, IEnumerable<Flights>>
    {
        private readonly IFlightRepository _repository;

        public GetAllFlightsHandler(IFlightRepository repository)
        {
            _repository = repository;
        }

        public Task<IEnumerable<Flights>> Handle(GetAllFlightsQuery request, CancellationToken cancellationToken)
        {
            return _repository.GetFlightsAsync();
        }




    }
}
